home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2004 April
/
CMCD0404.ISO
/
Software
/
Shareware
/
Programare
/
sharp
/
wwwSharp_setup.exe
/
{app}
/
Examples
/
Data access
/
WebControls
/
index.hta
< prev
next >
Wrap
Text File
|
2003-12-04
|
3KB
|
104 lines
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>www-Sharp.ClrHost data access example</TITLE>
<META http-equiv="Content-Type" content="text/html; charset=windows-1252">
<META name="GENERATOR" content="MSHTML 6.00.2800.1264">
<META http-equiv="MSThemeCompatible" content="Yes">
<HTA:APPLICATION
id="appDataAccess"
WINDOWSTATE="normal"
SYSMENU="yes"
SINGLEINSTANCE="no"
SHOWINTASKBAR="yes"
SELECTION="yes"
SCROLLFLAT="no"
SCROLL="no"
NAVIGABLE="yes"
MINIMIZEBUTTON="yes"
MAXIMIZEBUTTON="yes"
INNERBORDER="yes"
CONTEXTMENU="yes"
CAPTION="yes"
BORDERSTYLE="normal"
BORDER="thick"
APPLICATIONNAME="www-Sharp data access example"></HTA:APPLICATION>
<OBJECT id="DataAccess" classid="clsid:4CC2B254-F4C7-4F52-881E-C2E10B14E003">
<PARAM name="AssemblyName" value="DataAccess">
<PARAM name="TypeName" value="wwwSharp.ClrHost.Examples.DataAccess">
</OBJECT>
<LINK href="DataAccess.css" type="text/css" rel="stylesheet">
<SCRIPT language="JScript">
function Initialize()
{
inputConnStr.value = "Provider=SQLOLEDB;Integrated Security=SSPI;Initial catalog=pubs;";
textSqlQuery.innerText = "SELECT * FROM authors";
try
{
OnBtnShowTablesClick();
}
catch(e) {};
}
function OnBtnExecuteClick()
{
try
{
DataAccess.ConnectionString = inputConnStr.value;
DataAccess.SqlQuery = textSqlQuery.innerText;
divOutput.innerHTML = DataAccess.ConvertQueryToHtml();
selectTables.ondblclick = "OnSelectTablesDblClick()";
}
catch(e)
{
window.alert(e.description);
}
}
function OnBtnSelectConnectionClick()
{
var locator = new ActiveXObject("DataLinks");
var conn = locator.PromptNew();
if (conn != null) inputConnStr.value = conn.ConnectionString;
OnBtnShowTablesClick();
}
function OnBtnShowTablesClick()
{
selectTables.innerText = "";
DataAccess.ConnectionString = inputConnStr.value;
selectTables.outerHTML = DataAccess.GetTableNamesForSelect("OnSelectTablesDblClick()");
}
function OnSelectTablesDblClick()
{
var tblName = selectTables.value;
textSqlQuery.innerText = "SELECT * FROM [" + tblName + "]";
}
</SCRIPT>
</HEAD>
<BODY onload="Initialize()">
<BUTTON id="btnSelectConnection" onclick="OnBtnSelectConnectionClick()">Connection
string:</BUTTON>
<INPUT id="inputConnStr" size="75">
<BR>
<BUTTON id="btnShowTables" onclick="OnBtnShowTablesClick()">Show tables</BUTTON>
<BR>
<LABEL for="textSqlQuery">Sql query:</LABEL>
<SELECT id="selectTables" onchange="OnSelectTablesDblClick()"></SELECT>
<BR>
<TEXTAREA id="textSqlQuery" rows="5" cols="50"></TEXTAREA>
<BR>
<BUTTON id="btnExecute" onclick="OnBtnExecuteClick()">Execute query</BUTTON>
<DIV id="divOutput"></DIV>
<DIV id="divFooter">
<P id="creator">Created with <A href="http://www-sharp.com/" target="_blank"><STRONG>
www-Sharp</STRONG></A>.</P>
</DIV>
</BODY>
</HTML>